home *** CD-ROM | disk | FTP | other *** search
- /**\
- |**| =====================================================================
- |**|
- |**| QDGX shell printing.c
- |**|
- |**| This file contains the printing routines for
- |**| the QuickDraw GX shell program.
- |**|
- |**| ©1992-1994 Apple Computer, Inc.
- |**| All rights reserved.
- |**|
- |**| =====================================================================
- \**/
-
-
- #include "QDGX shell.h"
-
-
- /**\
- |**| ---------------------------------------------------------------------
- |**| SetUpEditMenuRec()
- |**| This routine sets up an gxEditMenuRecord which references our edit
- |**| menu. This structure is used by the GXJobDefaultFormatDialog and
- |**| GXJobPrintDialog calls to allow cut, copy, & paste operations from
- |**| the dialogs.
- |**| ---------------------------------------------------------------------
- \**/
- void SetUpEditMenuRec (gxEditMenuRecord *edMenuRec)
- {
-
- edMenuRec->editMenuID = mEdit;
- edMenuRec->cutItem = iCut;
- edMenuRec->copyItem = iCopy;
- edMenuRec->pasteItem = iPaste;
- edMenuRec->clearItem = iClear;
- edMenuRec->undoItem = iUndo;
- }
-
-
- /**\
- |**| ---------------------------------------------------------------------
- |**| DoFormat()
- |**| This routine performs GX's equivalent of the Page Setup (PrStlDialog)
- |**| call of the old printing architecture.
- |**| ---------------------------------------------------------------------
- \**/
- OSErr DoFormat (WindowPtr wind, gxDialogResult *result)
- {
- OSErr err = noErr;
- gxEditMenuRecord edMenuRec;
- gxJob docJob;
-
- // If we have a non-nil WindowPtr, set up our edit menu record and handle the job
- // format dialog. Remember to check for errors.
-
- if ( wind != NULL )
- {
- docJob = GetDocJob(wind);
- SetUpEditMenuRec(&edMenuRec);
- *result = GXJobDefaultFormatDialog(docJob, &edMenuRec);
- err = GXGetJobError(docJob);
- }
-
- return err;
- }
-
-
- /**\
- |**| ---------------------------------------------------------------------
- |**| DoPrinting()
- |**| This routine performs GX's equivalent of the Print Job Dialog
- |**| (PrJobDialog) call of the old printing architecture, and then prints
- |**| the document if the user wants to.
- |**| ---------------------------------------------------------------------
- \**/
- OSErr DoPrinting (WindowPtr wind)
- {
- OSErr err = noErr;
- gxDialogResult result;
- gxEditMenuRecord edMenuRec;
- gxJob docJob;
-
- // If we have a non-nil WindowPtr, set up our edit menu record and handle the print
- // job dialog. Remember to check for errors. If no errors occur, and the user clicks
- // ok, print the window's document.
-
- if ( wind != NULL )
- {
- docJob = GetDocJob(wind);
-
- SetUpEditMenuRec(&edMenuRec);
- result = GXJobPrintDialog(docJob, &edMenuRec);
- err = GXGetJobError(docJob);
-
- if ( (result == gxOKSelected) && (err == noErr) )
- err = DoPrintOne(wind);
- }
-
- return err;
- }
-
-
-
- /**\
- |**| ---------------------------------------------------------------------
- |**| DoPrintOne()
- |**| This routine prints one copy of the window's document using whatever
- |**| job and format is currently attached to it. (If the window were just
- |**| created and then the user selected Print One w/o first selecting Page
- |**| Setup…, the system default job and format are stored with this document.
- |**| ---------------------------------------------------------------------
- \**/
- OSErr DoPrintOne (WindowPtr wind)
- {
- OSErr err = noErr;
- gxJob docJob;
- Str255 title;
-
- // If we have a non-nil WindowPtr, start the print job, print a page and then finish
- // the job. Since we have just a one page document, we don't bother counting pages.
- // Remember to check those errors!
-
- if ( wind != NULL )
- {
- docJob = GetDocJob(wind);
- GetWTitle(wind, title);
-
- GXStartJob(docJob, title, 1);
- err = GXGetJobError(docJob);
-
- if ( err == noErr )
- {
- GXPrintPage(docJob, 1, GXGetJobFormat(docJob, 1), GetDocShape(wind));
- err = GXGetJobError(docJob);
- }
-
- GXFinishJob(docJob);
- if ( err == noErr )
- err = GXGetJobError(docJob);
- }
- return err;
- }
-
-
-
-